$(document).ajaxSend(function(event,xhr,options){
     xhr.setRequestHeader("userToken", localStorage.getItem("userToken"));
 });

 $(document).ajaxError(function(event,xhr,options,exc){
    if(xhr.status==401){
        location.href = "blog_login.html";
    }
})

function getUserInfo(url){
            $.ajax({
                type: "get",
                url: url,
                success: function(ret){
                    if (ret != null && ret.code=="SUCCESS" && ret.data!=null){
                        $(".container .left .card h3").text(ret.data.userName);
                        $(".container .left .card a").attr("href", ret.data.githubUrl);
                    }
                }
            });
        }

function logout(){
    localStorage.removeItem("userToken");
    localStorage.removeItem("userId");
    location.href = "blog_login.html";
}